package com.bossien.flink.config;

import com.bossien.flink.interfaces.IEnviroment;
import lombok.Data;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.springframework.context.annotation.Configuration;

/**
 * @author 胡春林
 *批处理对象
 */
@Configuration
@Data
public class ExecutionEnviromention implements IEnviroment {

    private ExecutionEnvironment excutionEnviroment;

    //启用闭包清理器（默认启用）
    //private boolean closureCleaner;
    //设置作业的默认并发度
    private String parallelism;
    //设置作业的默认最大并发度
    private String maxParallelism;
    //设置失败任务重试次数(已弃用)
    private int numberOfExecutionRetries;
    //设置执行模式来执行程序 默认PIPELINED
    private String executionMode;
    //用户将自定义对象设置为作业的全局配置
    private String GlobalJobParameters;
    //设置在连续尝试取消正在运行的任务之间等待的间隔（默认30s）
    private long taskCancellationInterval;
    //时间戳间隔
    private long autoWatermarkInterval;
    //任务重试次数
    private int failureRate;
    //任务失败间隔
    private Time failureInterval;
    //任务失败延时重试间隔
    private Time delayInterval;
    //session超时
    private long sessionTimeout;

    @Override
    public ExecutionEnvironment  init() {
        //开始进行配置
        this.excutionEnviroment = ExecutionEnvironment.getExecutionEnvironment();
        //ExecutionConfig executionConfig = excutionEnviroment.getConfig();
        //executionConfig.setRestartStrategy(RestartStrategies.failureRateRestart(failureRate,failureInterval,delayInterval));
        return this.excutionEnviroment;

    }

    @Override
    public void destory() {this.excutionEnviroment = null;}
}
